home *** CD-ROM | disk | FTP | other *** search
- Path: dispatch.news.demon.net!demon!redifon.demon.co.uk
- From: Guy Pickering <gp@redifon.demon.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Mutexes make const functions impossible!?
- Date: Thu, 29 Feb 1996 12:26:10 GMT
- Organization: Redifon MEL Ltd
- Message-ID: <825596770.4813@redifon.demon.co.uk>
- NNTP-Posting-Host: redifon.demon.co.uk
- X-NNTP-Posting-Host: redifon.demon.co.uk
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3_U1 sun4c)
- MIME-Version: 1.0
- X-URL: news:comp.lang.c++
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
-
- Usually, my classes have a number of const functions for getting internal
- data (e.g. getWidth(), getNumEvents()). My problem is that when I wish
- to be thread-safe, I need to lock and unlock a mutex every time I access
- internal data. This means my functions can no longer be const because the
- mutex member is being locked and unlocked.
-
- Is this a situation where the const'ness should be cast away, or am I
- dammed to throw away all const'ness from thread-safe functions. Or is
- there another solution?
-
- Thank you for your time.
-
- Guy
-
- --
- Name: Guy Pickering B.Eng A.M.I.E.E
- Position: Software Engineer
- Company: Redifon MEL Ltd, Newton Rd, Crawley,
- West Sussex, RH10 2TU. ENGLAND
- Tel: +44 (0)1293 518855 Fax: +44 (0)1293 530101
- Mobile: +44 (0)973 129362 (Orange)
-
-